

var app=new Vue({
    el:"#player",
    data:{
        musicName:"",
        musicList:[],
        //歌曲地址
        musicUrl:"",
        //歌曲封面
        musicCover:"",
        //热门评论
        hotCommentList:[]  ,
        //歌曲MV
        mvUrl:"",
        //封面状态
        isPlaying:false,
        // 遮罩层状态
        isShow:false
    },
    methods: {
        searchMusic: function () {
            var tais = this
            axios.get("https://autumnfish.cn/search?keywords=" + this.musicName)
                .then(function (response) {
                    //console.log(response.data.result.songs)
                    tais.musicList = response.data.result.songs;
                })
        },

        //播放歌曲
        playMusic: function (musicId) {
            var that = this;
            axios.get("https://autumnfish.cn/song/url?id=" + musicId)
                .then(function (response) {
                    //console.log(response.data.data[0].url)
                    that.musicUrl = response.data.data[0].url;
                }, function (err) {
                })

            //歌曲封面
            axios.get("https://autumnfish.cn/song/detail?ids="+musicId)
                .then(function(response){
                    //console.log(response.data.songs[0].al.picUrl)
                    that.musicCover = response.data.songs[0].al.picUrl;
                },function(err){})

            axios.get("https://autumnfish.cn/comment/hot?type=0&id="+musicId)
                .then(function(response){
                    //console.log(response.data.hotComments)
                    that.hotCommentList = response.data.hotComments;
                },function(err){})

        },
        // 歌曲播放
        play: function() {
            // console.log("play");
            this.isPlaying = true;
        }  ,
        // 歌曲暂停
        pause: function() {
            // console.log("pause");
            this.isPlaying = false;
        },  // 播放mv
        getMV:function(mvid) {
            var that = this;
            axios.get("https://autumnfish.cn/mv/url?id="+mvid).then(
                function(response) {
                    console.log(response.data.data.url);
                    that.isShow = true;
                    that.mvUrl = response.data.data.url;
                },
                function(err) {}
            );
        },
        hide:function() {
            this.isShow = false;
        }
    }
})